#ifndef PERSONINDEX_H
#define PERSONINDEX_H

#include <QObject>
#include <QWidget>
#include <QMouseEvent>
#include <QString>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSpacerItem>
#include "blogitem.h"
#include "bloginfo.h"
#include "showblog.h"
#include "publishblog.h"
#include "publishres.h"
#include "showres.h"

class PersonIndex : public QWidget
{
    Q_OBJECT
public:
    explicit PersonIndex(QWidget *parent = nullptr);
    ~PersonIndex();
    void addBlogItem(QMap<QString, QString> map);
    void addResItem(QMap<QString, QString> map);
    void addCommentItem(QMap<QString, QString> map);
    void showBlog(QMap<QString, QString> mapInfo, int type);
    void showRes(QMap<QString, QString> mapInfo);
    void publishBlog();
    void publishRes();
    void removeRight();
    void setAuthorName(QString name);
    void setAuthorHead(QString path);
    void setOtherInfo(QString info1, QString info2, QString info3);
    void setPraise(bool isPraise, QString p);
    void setCollection(bool isCollection, QString c);
    void setComment(QString c);
    void showComment(QMap<int, QMap<QString, QString>> map);
    void appendComment(QMap<int, QMap<QString, QString>> map);
    void removeComment();
    QString getPraise();
    QString getCollection();
    QString getComment();
    QList<BlogItem *> itemList;
    QString blogUser, blogStamp;
    bool isShowComment=false;
private:
    QVBoxLayout *vLayout;
    BlogInfo *blogInfo;
    ShowBlog *sblog;
    QWidget *commentWidget;
    QTextEdit *commentText;
    QVBoxLayout *commentLayout;
private slots:
    void slotBlogOperation(QMap<QString, QString>, QString msg);
    void slotBlogInfo(QMap<QString, QString>, int);
    void slotDownloadRes(QMap<QString, QString> map);
    void slotUserRes(QString);
    void slotPublishRes(QMap<QString, QString> map);
    void slotPublishBlog(QMap<QString, QString> map, QList<QString> list);
    void slotComment();
signals:
    void signalBlogClicked(QMap<QString, QString>, QString msg);
    void signalBlogClicked(QMap<QString, QString>, int);
    void signalDownloadRes(QMap<QString, QString> map);
    void signalPublishRes(QMap<QString, QString> map);
    void signalUserRes(QString);
    void signalPublishBlog(QMap<QString, QString> map, QList<QString> list);
    void signalComment(QString com);
};

#endif // PERSONINDEX_H
